﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using System.Diagnostics.Contracts;

namespace ShredTheLog.Api.DataContracts.TextChat
{
    public interface ITextChatCommand
    {
    }

    public abstract class RoomCommand : ITextChatCommand
    {
        [XmlAttribute("R")]
        public string RoomName { get; set; }
    }

    [XmlRoot("E")]
    public sealed class EnterRoomCommand : RoomCommand
    {
    }

    [XmlRoot("FP")]
    public sealed class FlashPenCommand : RoomCommand
    {
    }

    [XmlRoot("C")]
    public sealed class RequestPrivateChatCommand : ITextChatCommand, IUserInfo
    {
        [XmlAttribute("UID")]
        public int Uid { get; set; }

        public RequestPrivateChatCommand(IUserInfo user)
        {
            Contract.Requires(user != null);

            Uid = user.Uid;
        }
    }

    [XmlRoot("M")]
    public sealed class SendMessageCommand : RoomCommand
    {
        [XmlText]
        public string MessageText { get; set; }
    }

    [XmlRoot("CR")]
    public sealed class SysMessageCommand : SysMessage, ITextChatCommand
    {
        public SysMessageCommand(IUserInfo user, RequestAnswer answer)
        {
            Contract.Requires(user != null);

            Uid = user.Uid;
            Answer = answer;
        }
    }
}
